module.exports = options => {
  return async function permission(ctx, next) {
    console.log('3..........');
    const token = ctx.get('Authorization').substring(7);
    if (token) {
      try {
        // 解码token
        const decode = ctx.app.jwt.verify(token, ctx.app.config.jwt.secret);
        console.log('9...', decode);
        await next();
      } catch (error) {
        ctx.status = 401;
        ctx.body = {
          s: 0,
          msg: error.message,
          d: {}
        };
      }
    } else {
      console.log('20...', ctx.status);
      ctx.status = 401;
      return ctx.body = {
        s: 0,
        msg: '没有token',
        d: {}
      };
    }
  }
}